import React, { Component } from 'react';
import MyTable from '../component/myTable';
import MyForm from '../component/myForm';
class Operatelogs extends Component {
    constructor(props) {
        super(props);
        this.state = {
            /* tableInfo  */
            tableInfo: {
                delectUrl: '1111111111',
                search:{
                    searchUrl: 'api.tPipeDeviceList',
                    info: [
                        { label: '设备类型', type: 'selectOne', key: 'deviceType', info:[{id:'1',name:'阀门'},{id:'2',name:'门站'}]},
                        { label: '设备名称', type: 'input', key: 'deviceName' },
                    ]
                },
                btn:false,
                // btn: [
                //     // { label: '新增', key: 'listId', type: 'add' },
                //     // { label: '批量刪除', key: 'listId', type: 'rowDelect' }
                // ],
                tableEdit:[],
                columns: [
                    { title: '管理账号', dataIndex: 'adminName', align: 'center' },
                    { title: '模块', dataIndex: 'moduleId', align: 'center' },
                    { title: '页面', dataIndex: 'pageId', align: 'center' },
                    { title: '操作项', dataIndex: 'itemId', align: 'center' },
                    { title: '日志说明', dataIndex: 'logInfo', align: 'center' },
                    { title: '记录时间', dataIndex: 'createTime', align: 'center' },
                ]
            },
            formInfo:{
                visible: false,
                addUrl: 'api.sysAdminLogAdd',
                updateUrl: 'api.sysAdminLogUpdate',
                label: [
                    { theKey: 'adminId', type: 'text', label: '', master: false },
                    { theKey: 'adminName', type: 'text', label: '', master: false },
                    { theKey: 'createTime', type: 'text', label: '', master: false },
                    { theKey: 'itemId', type: 'text', label: '', master: false },
                    { theKey: 'logInfo', type: 'text', label: '', master: false },
                    { theKey: 'moduleId', type: 'text', label: '', master: false },
                    { theKey: 'orgId', type: 'text', label: '机构ID', master: false },
                    { theKey: 'pageId', type: 'text', label: '', master: false },
                ],
                info: '',
            }
        };
    }
    componentDidMount() {

    };
     /* table back */
    tableBack=(type,info)=>{
        console.log(type)
        if(type==='add'){
            this.setState({
                formInfo:Object.assign({},this.state.formInfo,{visible:true})
            })
        }else if(type==='update'){
            this.setState({
                ceshi:Object.assign({},this.state.formInfo,{visible:true})
            })
        }
    }
    /* form back */
    formUpdata=(type)=>{
        console.log(type)
        if(type==='refresh'){
            this.setState({
                tableInfo:Object.assign({},this.state.tableInfo,{refresh:false})
            })
        }
        this.setState({
            formInfo:Object.assign({},this.state.formInfo,{visible:false})
        })
    }
    render() {
        return (
            <div>
                <MyTable info={this.state.tableInfo} tableBack={this.tableBack}></MyTable>
                <MyForm formInfo={this.state.formInfo} formUpdata={this.formUpdata}></MyForm>
            </div>
        );
    }
}
export default Operatelogs;